<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

//factory database to create object plexiable
class model_topic_server extends model_topic{
    
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function get_all(){
        $query = $this->db->get_where($this->config->item('database_suffix').'topics',array('is_deleted' => false));
        return $query->result();
    }
    
    function get($int){
        
    }
    
    function insert($data){
        
        $this->db->insert($this->config->item('database_suffix').'topics', $data);
        $this->db->select('max(id) as id');
        $this->db->from($this->config->item('database_suffix').'topics');
        $id_max=-1;
        $query=$this->db->get();
        $object=$query->result();
        return $object[0]->id;
    }
    
    function update($int,$data){
        $this->db->where('id', $int);
        $query=$this->db->update($this->config->item('database_suffix').'topics', $data);
        //var_dump($query);
        return $query;
    }
    
    function delete($int){
        $this->db->where('id', $int);
        $query=$this->db->update($this->config->item('database_suffix').'topics', array("is_deleted"=>true));
        //var_dump($query);
        return $query;
        
    }
}